Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the "-" sign on Bun option for create-next-app CLI tool in the documentation #64972

Merged
merged 2 commits into from
Apr 24, 2024

Conversation

begalinsaf
Copy link
Contributor

What?

this is just small changes for this doc https://nextjs.org/docs/app/api-reference/create-next-app#interactive

Why?

because bunx create-next-app is incorrect command for bun, if you run that command it will given error like this

$ bunx create-next-app
error: Script not found "create-next-app"

How?

i just removed the "-" sign on bun option, so its must be like this

bunx create next-app

its just simple PR, because "bunx create-next-app" is incorrect command for bun
@begalinsaf begalinsaf requested review from a team as code owners April 24, 2024 12:45
@begalinsaf begalinsaf requested review from molebox and delbaoliveira and removed request for a team April 24, 2024 12:45
@ijjk ijjk added the Documentation Related to Next.js' official documentation. label Apr 24, 2024
@ijjk
Copy link
Member

ijjk commented Apr 24, 2024

Allow CI Workflow Run

  • approve CI run for commit: 69347c9

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

1 similar comment
@ijjk
Copy link
Member

ijjk commented Apr 24, 2024

Allow CI Workflow Run

  • approve CI run for commit: 69347c9

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Copy link
Member

@samcx samcx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting a :pr:!

:lgtm:

@samcx samcx enabled auto-merge (squash) April 24, 2024 21:08
@samcx samcx merged commit 9c0d792 into vercel:canary Apr 24, 2024
33 checks passed
samcx added a commit that referenced this pull request Apr 25, 2024
### What?

Corrects the Bun install command (again) on [this
page](https://nextjs.org/docs/app/api-reference/create-next-app#interactive)
of the docs.

### Why?

The Bun instructions were originally created in
7e16538 with a correct command to
create a new Next.js project with Bun: `bunx create-next-app`.

Then, it was changed to `bunx create next-app` in
2ab4a44, which isn't correct because
`bunx` acts like `npx` and tries to run a nonexistent package called
`create`, specifying `next-app` as its argument.

This change was reverted in a42efae two
weeks ago, and a PR from today (#64972) reverts that correction.

Both `bunx create-next-app` and `bun create next-app` work on my machine
as of Bun 1.0. `bunx create-next-app` is analogous to `npx
create-next-app`, and `bun create next-app` is the same as `npm create
next-app`.

| Command | Correct? | Similar NPM command | Note |
|---|---|---|---|
| `bun create next-app` | ✅ | `npm create next-app` |
My proposed change |
| `bunx create-next-app` | ✅ | `npx create-next-app` |
|
| `bunx create next-app` | ❌ | `npx create next-app` (incorrect) |
Currently listed in the Next.js docs |
| `bun create-next-app` | ❌ | `npm create-next-app` (incorrect) | |

I think this confusion is caused by having two valid ways to run
`create-next-app` with two very similar syntaxes. **It could be
beneficial to include a note explaining the two correct syntaxes** to
avoid future confusion, but for now, I have just changed `bunx` -> `bun`
to keep the command similar to `yarn` and `pnpm`.

Co-authored-by: Sam Ko <sam@vercel.com>
@abdoufma
Copy link

abdoufma commented Apr 25, 2024

Actually, bunx create-next-app works perfectly fine, as does bun create next-app. they are identical in behaviour

This is to be expected, as they are supposed to be the bun equivalents of npx create-X and npm create X, respectively.

UPDATE: output for both commands
Screenshot 2024-04-25 at 15 55 19
Screenshot 2024-04-25 at 15 53 54

@begalinsaf
Copy link
Contributor Author

begalinsaf commented Apr 26, 2024

@abdoufma I don't quite understand what the issue is, and I've tried bunx create-next-app with bash, zsh, and PowerShell; it works fine. But for cases with terminals like Command Prompt, it will give an error.
However, for the bunx create next-app command, it might work well on all OS and terminals. That's why I created a PR providing a flexible solution so that the command can run on everything.

Screenshot (14)
Screenshot (15)

@begalinsaf begalinsaf deleted the patch-2 branch April 26, 2024 10:53
@abdoufma
Copy link

abdoufma commented Apr 26, 2024

It’s peculiar that bunx create next-app works for you at all, since It’s the only one that doesn’t for me. (bun create X works, bunx create X doesn’t)

That's not too surprising, as It’s not documented anywhere that it should work; bunx create next-app essentially looks for the create package and attempts to execute its bin script, passing next-app as an argument (which should fail).

Both bunx create-next-app and bun create next-app worked as expected on linux and macOS (using both zsh and bash), and on Windows 10/11 (using both CMD and powershell)

bunx create next-app doesn't work anywhere.

Results of executing all three command on windows powershell and CMD:
windows_powershell
windows_CMD

@samcx
Copy link
Member

samcx commented Apr 26, 2024

Thanks for the re-clarifications. It's likely a separate issue causing bunx to not work, but since the :bun: docs primarily use bun create, we'll stick with that.

@abdoufma
Copy link

@samcx Agreed. A command supported by all package managers is prefered.
In that case however, shouldn't the npm instruction be similarly switched to npm create next-app ? 🤔

@begalinsaf
Copy link
Contributor Author

begalinsaf commented Apr 26, 2024

Thanks for the explanation; now I understand. Sorry if I caused any confusion. I thought I could help by providing this PR, and the developers approved it. I just thought it could help everyone. I didn't expect there would be a debate about this. I'm not an expert in anything, and thanks for clarifying; now I get it. Thank you, developers, for reviewing this PR.

@samcx
Copy link
Member

samcx commented Apr 26, 2024

@abdoufma I'm not seeing npm create being mentioned, but I do still see npxhttps://docs.npmjs.com/cli/v10/commands/npx.

@abdoufma
Copy link

abdoufma commented Apr 26, 2024

@samcx Admittedly, finding the relevant documentation wasn't easy at first, but npm create is essentially an alias for npm init which in turn calls npm exec

And as per npm init's docs:

npm init <initializer> can be used to set up a new or existing npm package.
initializer in this case is an npm package named create-<initializer>, which will be installed by npm-exec, and then have its main bin executed -- presumably creating or updating package.json and running any other initialization-related operations.

@abdoufma
Copy link

In other words: npm create X, npm init X, npm exec create-X, and npx create-X are all different ways to achieve the same outcome.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Related to Next.js' official documentation. locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants